import api from "../../api"

// 获取角色列表
const getRoleList = function (params) {
  return api.getRequest(api.requestURL + 'web' + api.apiVer + 'roles', params)
}

// 角色添加或更新
const saveOrUpdateRole = function (params) {
  return api.postRequest(api.requestURL + 'web' + api.apiVer + 'roles/saveOrUpdate', params)
}

// 删除角色
const deleteRole = function (id) {
  return api.deleteRequest(api.requestURL + 'web' + api.apiVer + `roles/${id}`)
}

// 分配人员
const rolesAssignUser = function (id, params) {
  return api.postRequest(api.requestURL + 'web' + api.apiVer + `roles/${id}/assignUser`, params)
}

// 获取分配人员信息
const rolesGetAssignUser = function (id) {
  return api.getRequest(api.requestURL + 'web' + api.apiVer + `roles/${id}/getAssignUser`)
}

// 根据id查询角色信息
const getRoleDetail = function (id) {
  return api.getRequest(api.requestURL + 'web' + api.apiVer + `roles/${id}`)
}

// 获取分配菜单信息
const rolesGetAssignMenu = function (id) {
  return api.getRequest(api.requestURL + 'web' + api.apiVer + `roles/${id}/getAssignMenu`)
}

const rolesAssignMenu = function (id, params) {
  return api.postRequest(api.requestURL + 'web' + api.apiVer + `roles/${id}/assignMenu`, params)
}

export default {
  getRoleList,
  saveOrUpdateRole,
  deleteRole,
  rolesAssignUser,
  rolesGetAssignUser,
  rolesGetAssignMenu,
  rolesAssignMenu,
  getRoleDetail
}
